Refactor finite stream implementation