Use CAMLparam/CAMLreturn when doing caml_failwith.
Reverted Console.{log_s,write_all}.