Use std::unique_ptr in the GC

This makes the code much cleaner and safer, and much more idiomatic
C++.