Functionalization of carbon nanomaterials with nitrogen, halides and oxides