Extracted listener support to own class, and other changes.