fixed a bug with polykinded categories
generate category instances with template haskell; some new instances and refactoring