fix crashes in lua