Some more re-factoring to preserve backwards compatibility and simplify.