mismatched memory deallocation bug resolved