Refactor methods based on CodeClimate analysis.