Cleaned up some locking.
Way more logging.