Minor code cleanup and fixed variable naming