Fixing a delete vs. free problem