Simplify code.

We can delete the objects earlier now that we are copying the names to a buffer.