Some cleanup in the listener