Make %ensure-stream a function

Also reorganize a bit