Many improvements to the way the audit scope is calculated. Also fixed ticket #145.
Cosmetic changes.