Minor bugfixes in garbagecollection