Bugfixes

Fixing the numerous mistakes I made last night because I rushed the
commit.