Bugfixes in merge.py