REFACTOR: Code moved around into 'modules' to make it a bit more organised. Needs more comments.