Fix backtracking process

callcc hack is just a kludge and should be rewritten.