Defects and doping and their role in functionalizing graphene