Fix undefined index state. Closes #1744