Added in some more checking.