Stylesheet optimizations and code reorganization