Unsigned/signed arithmetic bugfix