Scrollback fixes

Should fix #772 and #778