Fixed bugs in polling and callbacks.