Cleaning up various places in the codebase, adding more documentation.
Various cleanups and modifications, using new acessor to clean up modules.