Debugged merging (turns out the problems were due to errors in managing the circular linked list of backward edges).