code cleanup - reduce global vars