stream: properly cast length