Isolate the writing of history files in optimize_surface_exact.m. Introduced switch to choose whether history file is saved or not.
Isolate code to find regions in separate function. Now easier to read.