Stability and Core-Level Signature of Nitrogen Dopants in Carbonaceous Materials