4.0 work

Fixes some validation problems, enforces permissions when adding tags and fixes some other bugs.  Also adds a test.