Reduce logging, adjust the while clause to prevent core dumps in the merge function.