Fix some arithmetical errors

Can I remove all the comparisons?