better handling of term insert errors

see https://github.com/GigaOM/legacy-pro/issues/2093
more sanity checking

See https://github.com/GigaOM/legacy-pro/issues/2174
thank you @methnen
thank you again, @methnen
ugh
Merge pull request #60 from misterbisson/bug-fixes

Bug fixes