Factor out disable-expensive-modes function.