UMS: cppcheck fixes

remove unused variables
reduce some variables scopes
minor coding styles fixes