Changed priority calculations. Bug fix in MainProc