Do proper cleanup when exiting world; fixed many memory leaks