Refactor with action bar callbacks. Improved interaction with database.