Fixed bug in flat_merge()