Fix some warnings

Fix some gcc warnings (signed/unsigned comparison)
Fix some cppcheck warnings (Performance: possible inefficient checking emptiness).