Fixed the bug in the folkman code - now to port over to C/C++ and optimize!