Adds a proper error messages and fixes undefined keys

This will yield a better error message and also fix undefined fields in PluginError.