refactor layout cache