Rewrite whole type system