Various fixes re. type variables

Fixes #75, #82 and #87 
Import? I didn't see a name collision.