Fix most compiler warnings

The fixes for unused variable warnings are pretty straight-forward, as are most others. It's mostly  	784767d and the two last ones that I'm not entirely sure about.

There are some unsigned vs. signed comparison warnings that are still unfixed (mostly those that compare iClientIndex to something). If anyone has suggestions on how to fix those, please tell.