Added proper JSON thread updater.

And embedded the database setup queries files, plus various
improvements.