OCaml 4.02: port some of the fixes for typechecker slowdown