fix various bugs in circuit.py and stream.py