Moved all type handling code into the functions.
Moved error reporting out of location class.