Refactor: fix code smells.

Reduce complexity as suggessted by code climate.