some big fixes in merge_data.py