Some improvements to the type system