Changing the module type, and refactoring and rewriting some parts of the code