Formatting.
First part of some changes to allow types to have functions.

This is mainly bugfixes to stop the compiler from crashing on edge
cases.