remove some unnecessary code, rename several variables, general cleanup