Remove stdin_stream as a module global

Use it as data passed to the callbacks. This will improve reuse of this code in
the future