fixup permissions and template