more work on reading/writing messages to DB