More graceful JSON error handling

A few more issues fixed, and handles plugin JSON errors too.