remove sleep from loop
remove unused mutex
minor cleanup/changes