Started refactoring code into final modules.