Al least one error is in the table iteration:
lua_pushnil(mpLuaState); /* first key */ while (lua_next(mpLuaState, -1))
Jan