Code cleanup and result saving.