rewrite stream and serializer