More refactoring of sequence code