Adding recent bugfixes to the backtracking branch.