Some minor code reorg
Add some new typeclasses