Fixed merging order (and flipped functions for consistency)