Added fix to not add "required" attr unless field is actually required.
Merge commit '816b527c52e60c89865d68b1e8e1d7e0a302cc6c'
Minor cleanup of #405.