code cleanup

also an attempt to fix the naggy undeclared var spam on dev branch