Refactored code (listeners, etc)