More cleanup/polishing of threads/locking