ocaml maxrects implementation