Fix bug 1646. Fix repeated recomputation of timeouts. Be a little more conservative about buffer changes.