Redirect IO stream, define data struct