Trimmed use of some globals. Removed use of mutex - bit risky, unsure if there are consequences