create wrapper class for std::functions, and lua functions to keep track of them. fix some uses of std::functions.