Updated / rewrote the type checker