Fixed a comparison with -1 to 0, since we now use unsigned datatypes in the optimization