Fixed mail fetching and keeping the count in the database.