Clearing deadlocks in Engine::reset() and Engine::clear()