Correctly handle the failure of Lua functions when results are expected.
Fix issues with callback refs.