Fixing signed/unsigned integer comparison mismatch