Refactor listener and observer into modules.