Fix tracebacks when prefix not specified.

This fixes #6886 by accounting for instances where the prefix is not
specified, catching the KeyError exceptions.
Merge pull request #6888 from terminalmage/issue6886

Fix tracebacks when prefix not specified.