a bunch of bugfixes