Refactored to improve code climate scores

I'm also opening this to see how CI likes it.