Remove global var
Simplify ifs
Remove ;