Mostly aesthetic changes, but now the output file renaming is more robust.