Add support for Lua coroutines and fix message handling issues