fix off-by-one error in stream optimization
move the stream operator to the RHS when possible
special case for stream op on LHS of assign