Handle registration to the app server correctly (not finished yet)