Fix display of JS errors, and add argument checks to all tealight module functions.