Broken out some classes and added some utility functions