Debugged stl merge logic