lots of bugfixes