Correcting mixup betweean min and max values

Correcting mixup betweean min and max values.
Adds code to handle upgrade from version without this
fix.