Extracted 'break'/'continue' aggregation into common helper function.

Also addressed other CR feedback. Still need tests.