Refactoring, implementing listeners and communication protocols