Various cleanups (care of pyflakes)
Template definition patterns; generic publish dirs

Had to fix depth_first of Structure.walk as well.