Several more bugfixes