Lots of small fixes to get jex-events working with the database correctly.