Add some checks for bad data