Added some asserts for typechecking