v3.4: code for chained fits (faster and very robust)