Some critical bugfixes