Misc bugfixes

Thanks to ZementBlock for the bug reports