proper flushing of accumulated values when channels close
use cond-case where it makes sense
fix typehint