consolidated single-threaded refactor, removed all locks