Rebuild using type-level lists

This is a major refactoring!