refactor and simplify pub/sub system and account events polling