Major code re-factoring