Optimize memory use for large diamonds
Remove duplication in calculating row indentation
Reformat for loops