Fixes inbox#3260 (closed)
Use after free happens during scrolling, as the deleted spobjects are still kept inside by the Layout, which we iterate over later. Rebuilds the layout before we use it.
Also some very light refactoring. Just remove some nesting, grammar in docs and a bit of gratuitous modification.