Added further assertions and support for custom types