Updated the module manager to include more template functions and documentation in generated code. More refactoring.