some code cleanup and renaming