added priority queue and reworked clock delay determination