Bugfixes

boreq@d1ba257 is just a proposition, I tried to clean it up a bit.