Refactoring code to move into right packages