Refactor required/optional/forbidden. Closes #340