Move nsql publishing to its own thread.

Publishing was hanging the main lua update thread.
'data' and 'result' is too generic for a global variable. Rename them to make them easier to identify what they are?