Fix listen before register bug