Fixed several warning messages (mostly -Wreorder and signed/unsigned comparison).