fix some unsigned <-> signed conversion and unused variable warnings