Use variants instead of bootleg enum stuff.

This contains a refactor. It remains to be seen if it's working.