Added flush before registering callbacks
Bug in assigning callbacks