Fix signed vs unsigned comparisons

Some more changes to help Apple.