A ton of refactoring around currying support and typedefs