Refactorings

Raising the code climate score back to 3.5x. Please try to keep it that way :)