I think porting your program to Haskell would make all of your bugs logic errors, rather than only most of them.