Fix selection drawing regression introduced in 4f2052b.
Socket/net adjustments.
Clear the selection when it is invalidated.
Disable unlimited history when explicitly specified (009e15e).