improvements to layout engine