Use debug library if available.
Fix calling convention, fix parameter default, helps in porting example programs.