complete refactoring of cmsapp