Extract registration JS to separate file; add better error message support