CLOUDIFY-2517 added logging, some refactoring