Refactor proxy JavaScript ahead of fixes.
Slightly cleaner sqlite based IPC for Galaxy Proxy.