Refactor to make future changes easier

Just split things into separate files.