CLOUDIFY-2092 some refactoring.