Cleanup header -- move most of the implementation to the implementation file
Refactoring for maintainability