Better adaptive algorithm

Signed-off-by: John McCutchan <john@johnmccutchan.com>