Added closing of streams