Be defensive against bad input.