Backport fix incorrect behavior with priorities

See #24