Remove tabdict and other improvements and bugfixes

This is a major rewrite.