a bunch of final bugfixes