I must admit I do not understand the purpose of the remaining code in the file.

Generally the level of comments have been nice but things get convoluted here. There are references to scrolling but I do not see any code which is moving. If there is so renferences to these would be nice. Also I would expected this to be delegated to a 3rd party library not our own custom code.