Whitespace cleanup
Refactor duplicated code creating files
Refactor duplicated code determining filename
Handle patches with Index lines