Bugfixes

many, many bugfixes