Bugfixes

Lots of bugfixes