Improving merge algorithm.

svn path=/sandbox/; revision=83190