wrote some of the queue functions.