Refactors marketstat code into a module.