Add DEBUG flag and payload logging