fixes for regression after #72

Some fixes from other PR's got reverted in #72. Re-added those fixes!

My guess would be that #72 was not correctly rebased, so we should watch out for this kind of merges in the future!