Added templatedir to allow non-standard locations.