v1.3 small fixes to the algorithm