Major refactoring of code.
Major refactoring of code. Now works as modules.