Added assertions to type checker, tidyed up with generalized methods.