Add several sequence functions

as well as some initial PEP-8 cleanup.

The first FIXME needs resolution before merging.