fixed mismatched free/delete[]