Reducing cyclomatic complexity, DRY'ing up & random tweaks