Minor optimization, and add efficient debug logging for packet processing