more accurate threshold adaptation and speedups