Refactoring and added juju related functions