Complete interaction with database, fixed HistoryActivity.