working on threaded version
added mutex around @running
merge with timestamp changes