Fixed a serious bug in the engine.