Some additional minor tweaks and refactorings.