Refactored thread priority functionality