Pulled out the datatypes and general utility functions into separate source files.