Use newly exposed Engine function to read XML templates.

Clean up of some code. Make code adhere to the coding style.

Also support mods with 4 phases (only tested Ancient Empires).