Structure, order and the metallic state in polyaniline and its derivatives