added document level AI and method to calculate target AI from inside
document. fixed other AI calculating issues.