Moved more typeclass code into api side.

It all works in 2.10 with small adjustments and I really
need it in libsbt.