CodeClimate improvements

This change updates the code to fix problems found by CodeClimate