Added ToJSON instances for types. Cleaned up imports.