Fixed a bug causing the engine to crash on loading if the states in the XML file were not listed in order.