Lift free variables out of `loop`
Use same data representation as Java version
Merge pull request #29 from lpw25/master

Improvements to OCaml version