Refactoring to make nice packages