Added state loading function to StateEngine.