Fix InputStream leak (never close) and shadowing