Reconnect automatically after being kicked. Some refactoring.