Lots of small bugfixes all around