improve engine->disk and engine-run to use loop variables instead of holding state in engine