Fix keyerror referring to an empty variable.