Fix enum check, code cleanup

Generated automatically