Move wrapping of libpalay with globals from init.lua to C code
which is automated and produces slightly cleaner stack traces
on error.