Bug fixes

- Better handling if term insert errors, see https://github.com/GigaOM/legacy-pro/issues/2093
- More sanity checking, see https://github.com/GigaOM/legacy-pro/issues/2174