JFTR: I believe you are spot-on with the have_rows issue. Just yesterday, I stumbled over the error and narrowed it down to a single, lonely if ( have_rows('field') )
starting off the treatment of a flexible content field. And, like for the others here, the 5.1.2 update corrects it.