Added some type checks.