Cleanups (and a few lock_guards)