lots of refactoring into namespaced code