Moved types into their own module.
Separated code into logical files