standardize around null values and add some extra sanity checks