Cleaned up some unused and poorly-named variables, added support for remembering the scroll position in the history.