Fix warnings: signed/unisgned comparison, shadowing (in some cases global