Cleaning up namespaces and modules for api documentation

With these changes, the api documentation structure is relatively coherent.
You only need it where the namespace is defined.