Add terminal newlines, and tidy up the diff against upstream.