Bugfixes

Found a few mistakes.