greatly clean up code and locks by refactoring _refresh_wf