Pretty big change, reorganizing the file and cleaning up function names that made no sense for what they did.
Clean up some of the database functions.
Move onchange handler from HTML to JS.