Fixed some errors in database architecture