Fix recursion in InfiniteEncoder