Cleaned up code for queue_sink