Fix queue and priority treatment

 - Fix Ordering of queue
 - Calculate priority matrix on the base of last deviation
 - Fix loosing of priorities