CodeClimate Improvements

This change simplifies some code and reduces duplication to satisfy
CodeClimate.