- Moving the match statement in collectEdges outside the UDF.
- Removing left over commented out code from collectEdges.