Fix C++ compatibility warnings
Fix different signedness comparisons