Refactor; add ReGen support.