Prevent KeyError exception.

see #585