CFY-1308 some refactoring.