sync fixes, and open/close the database in main activity