Refactor listener handling.
Fix spacing styling.