Updated the calls to delete to remove the arrays that were allocated.