Cleanup and variable renaming