free memory when done. handle deleted objects