Improve performance so that it is closer to v1.1.0 performance. Fix remaining duo_mode errors.