Use std::unique_ptr to simplify memory management a bit.