Fix some input stream problems