Updated the handling of the Python callback functions