Fixed! There was a bug in the "change a nation to corpornation" code which messed up everything that came after it in the "end turn" sequence.