CFY-505 lots of code refactoring. both visual and logical