LPS-44886 Move the listener registration to the right place