Minor stuff
TODO check flush in every stream operation and check if all streams are correctly closed