Fixes to layout caching