Rewrite of one of the TSP functions, updated tests and docs, closing issues #127 and #156.