Fix misprints with help Cppcheck
It fix misprints, usage of index before checking, duplicated conditions, implicit converting -2 to unsigned number etc.
It fix misprints, usage of index before checking, duplicated conditions, implicit converting -2 to unsigned number etc.