several critical bugfixes