Fix some unreferenced local variable and fix warning  warning C4018: '<'...

... : signed/unsigned mismatch.