lots of minor changes and small bugfixes