factory: add hack for windows into stdin_loop()
factory: small refactoring run()