fix aggregators stopping

fix the bug that caused a listening aggregator to stop when a parent aggregator has stopped and sent it's state to output

plus some code style refactoring