fixed some bugs in type inference