Fixed parsing of input values to prevent bad values from being used