Minor variable renaming and refactoring to increase readability