Various fixes to associated types

These mostly derive from problems that @japaric encountered.

r? @pcwalton