Switched message sending to synchronise.

Due to errors being encountered with asynchronise message sending in
the JavaScript app I switched the code to do synchronise lookups.

I also added a central function for dispatching messages. This is in
place for when I get asynchronise lookups working as I want.