some refactoring, mainly namespaces, not complete