Fixed reverse mode.
Fix a bug in code related to alternate paths.
Some cleanup