Improved merge script.