Refactoring

Just cleaning up a little bit. The only major change here is using
properly cased names in the type definitions. Everything else is just
rearranged.