Fix memory leaks
Revert "[fix] TYPEP(x,y) should check x is not null too". Not needed

This reverts commit b63314aa7f196b7752f018c0904d3504772df97c.