From http://wilsonpage.co.uk/preventing-layout-thrashing/