Reorganize, add callback functions and parameters