Some refactoring of Javascript callbacks.

Also changed settings file to use javascript-friendly key names.