CLOUDIFY-2222 continue work, some refactoring