fixed comparisons between unsigned and signed integers

This commit removes some compiler warnings and some unneeded variables.