Fix for waiting on the queue. Some minor cleanup.