Improve comments and refactor form.js