Improved API for custom types