Fix bug where engine thread is optimized away