Reimplement types to use type descriptors

The type system now uses type descriptors instead of a simple enum.