Add event action and HB relations for pending tasks
Fix error in conting the number of open documents