Restructure and prepare for rewrite