fix planet IDs and memory leaks