Improve handling of newtypes (fixes Trac 1495)