local-ize a few variables
fix a copy&paste error, trim a couple redundant lines of code