A couple of bugfixes

I call this work "a sh*tload of bugfixes". Isn't it art-ish? :)