bunch of bugfixes