Integrate layout into template, cleanup