Fix 'link not found' on login. Fix potential memory leak.