improving stream API
fixing js issues