Fixed a bug in findFirstSolution, it seems to work now.