Modified for debugging the queueing. Clean up to be done.