Refactored code into a number of more targeted modules