some ugly bugfixes for some ugly bugs