misc fixes guarding against nulls and bash weirdness