Improved database logic for tweets