mod flow improvements, and sanitization fixes