Partial implementation of mark sweep.