Fix a bad optimization refs #3586
Merge commit '7169bf999f7c855e53d9abc43019546acf649f5f'