finished hard part of cleaning up type system