Added streams, some refractoring