Added ability to detect when queue is drained