primeLayout: rewrite to avoid iterated transformations
Merge pull request #22 from JohnLato/optimizations

primeLayout: rewrite to avoid iterated transformations