Fixed some null ref & using deleted object bugs