Pulled from realm
merged
Added referer handling.
Checked referrer-enabled signup.