merge_headers was overwriting input: fixed. This fixes register_image and resample_image too, I think.