Improved stdin/stdout management