Move a lot of code into a module as well.