Fixed some bugs in the return type checking.