Code revision and a few changes to help the GC.