Update for structured logging

Also a small bit of refactoring and fixing a race.