Clean up variables, add callback functions