many changes to variables, along with code cleanup