fixed concurrent db access problem (lesson learned: can't share the database object without locks)