Applied patch from liver Schmidt, correcting bugs #14543, #21138, #21933
Removed misleading comment :-)
Corrected nasty bug which would cause a crash when selecting only
Removed debug stuff at Chris' request.
Final touch on Chris' correction of the last history scrolling bug.
Fixed missing line in history (Chris' fix was at the wrong place).
Use buffer-based history until we optimise block array.
Set history correctly in new sessions.