Made logging more robust to nil values