refactoring and support for namespaces