adding locks to the cleanup stuff #111