Refactor the conversion functions into a class.

This makes it simpler to share state, like the Cfg pointer, and additional
state that may be needed in the future.