Fix auth workflow, clean up Javascript