Minor refactoring and variable renames.