Added sample code, fixed potential callback concurrency problems, added support for specifying dispatch queue to be used.