Fix Using Templates in World Factory

Makes templates usable again!
Also hopefully fixes the segfaults on game exit.