refactoring to namespaces and references