Microstructure, dangling bonds and impurities in activated carbons