Fix priority API + check priority validity