Gc improvements

This is the start of some work. It can be merged now or later though as this is good enough so far.