FIX callback functions and remove old code