Added before/after events for all and individual connections
Refactored events and connection handling