Move layout templates to lib; adjust script