Restructured functions.js and fix some errors

Errors fixed include semantic errors causing javascript errors when
checking for duplicates.
Section_content is now refreshed after a refresh of the current section
is complete in plex. (If triggered after deletion of subtitle)