refactor complete, no globals used