Fixed some entity generation and destroy bugs.