fix dup var in last commit
More pedantic fixes & little optimizations