Fixes to DB triggers, and add indexes
Merge pull request #52 from flibbertigibbet/feature/trigger-fixes

Fixes to DB triggers, and add indexes