New version with compartmentalized find_thetaset to avoid memory problems