Fixed a number of type-related errors