Refactor code for edit pages.