Began "translating" munsky's code.
The focus is on generalization and flexibility rather than efficiency right now.