Ported task_queue code over from CEE, making some adjustments for priority & updating code style on the way.  Compiles, but not tested.