Fixed the gatherData function and added options in the sidebar for the Optimize mode.