More fixes in db queries and twitter integration