Little bit of refactoring of the templates.

Also fixed issue where non xml files could be picked up by the
preferences processor.