Add generic message handler, and fix crashes caused by removing a message handler while a message is being handled
Add very basic initial Lua scripting support