Major refactor to use a more object oriented approach to generating types