Made modifications to match the latest uploadtemplate master.