Moved mainloop to OCaml

This makes the code simpler and easier to explain.

I assume noone else is setting "OS.Main.run" (but the difficulty of finding this out is perhaps a good reason to remove it).