Add some safety to type checks