Refactor a bit and move the module classes actually into the same js file (they might belong elsewhere.