Main re-factoring