Debugged type checker. Should be working