Fix bug where priority doesn't work.

Also, make sure the priority doesn't exceed the value for Required.