Eliminate global vars where not required