Refactors custom layout to follow Apple guidelines on when to
calculate attributes
Merge branch 'improvements'