Minor variable and code refactoring