More refactorings to correct warnings from RuboCop