Cleaning up file definitions, flatterning templates directory structure

and reducing dependencies.