Make g_dispatcher/g_scheduler objects

This saves us from dereferencing the pointers everytime we access
g_dispatcher/g_scheduler.
Fix MySQL reconnect code