Refactor layout templates