Fixed some bugs in error reporting and db updating