Reimplemented solve to be non-recursive with an explicit stack.
Passes all test cases for non-chronological backtracking.
Removed debugging statements and added statistics measurement statements.