Fixed object memory leaks on exit