Fixed bug where callback would sometimes not be called.