Bug fix

Fixed bug causing callbacks to be executed outside of the angular execution context.