Fixed a bug where not all ending nodes were added as start/end nodes