added inital/terminal node optimisation - more then halves running time