Assorted bugfixes
Support for case classes, need to have pattern matching/polymorphism for full support