Fixing input stream memoization