Fixed a bug in app registration code