Added some better error reporting and path handling when creating template paths.