Version 3.0 for database

Update and fix some bugs.