some more cleanup and bugfixes

Now done for the night