Was an embarrassing glitch in original optimization policy, the for-loops can't be de-duplicated here.