Some general bugfixes