Fixes scope issues with callback functions.