code cleanup and renaming for ease of reading