Finished most of type infer