Small fixes

Just a couple of minor fixes — simplified some ifs, removed a global var, etc