Compiler warning fixes

- unsigned/signed comparisons
- unused vars
- var init ordering
- missing cases in switches