Fix out-of-bounds access on the elements vector

Authored by vkrause on May 27 2018, 8:35 AM.