Smarter error handling and more refactoring

Input errors are now properly reflected in the DOM
through borders and messages, rather than alerts.
Also tidied up in comments and form views.