Fixing bugs after refactoring of Engine.