Made some changes to improve std input redirection

Still not quite working though.