Fixed styleCheck warnings like avoid while loops and mutable local
variables.