Gfate intergration

Proposed fix for activedocument management.
First pull request, hope I'm doing it right ;)