Started to improve error handling during LOOT init.

Also some settings file code refactoring.
Improved C++ <-> JS queries' error handling.

Also refactored query handling code a bit. Closes #134.