More refinement for logging, and helper functions.