Various changes to backtracking algo