Fix undefined variable. Closes #1301