Fixed PHP-621 (double free)

We need to copy the elements from cleanup_ids to the array passed to
->remove() so that we can free the returned array without messing up
the cleanup_ids array which is freed later.

The options array should also be freed after each call