fixed memory dealloc stack crashes