numerous small bugfixes