Refactor the overlapping element code to remove the time consuming recursion. Leads to huge speed ups in drawing of overlapping elements. Move to the Row class where it could be used elsewhere if needed.

Other minor clean ups.