Various issues discovered through new Sonar scanning that while not bugs, made code less maintainable. This addresses some of those issues.