Added the majority of the module code.