Some overflow fixes in the binary function