Clean up retrieving search data and fixed bug where flags may not persist