Work on garbage collection, and fix bugs