Refactor how options are extracted, stored, and used
Merge in options-cleanup branch