I would put purgeStreams() after the block below to avoid purging active stream if it's not drained.