Various small bugfixes