Changed save_template() to save in the last directory in the path.