stream.*: actually, just test if these functions exist.
improve finalize logic. move sgn setting back there and initialize more variables