NeroBurn crash

I have written a C++ app which writes a data file to a multi-session CD at regular intervals. The code is mainly taken from NeroCMD and sets options which correspond to:
–write --drivename e --real --disable_eject --close_session --iso test --iso-mode2 --create_udf_fs <filename>

I have two problems:

  1. The write works 99% of the time. The other 1%, it crashes from within NeroBurn. When it happens in the debugger, I get no call stack, just an obscure address. It seems to happen towards the end of the burn and is not related to the number of sessions already on the CD.
    I have run this on 5 PCs and the crash has occurred on all of them.

  2. Most of the time when the CD is full, NeroBurn ejects the CD, I insert a new one, and it carries on. But sometimes when the CD is full, NeroBurn returns ‘burn failed’. When I view the CD with IsoBuster, the final session is corrupted. It MIGHT be something to do the fact that I am burning tiny files - most of the CD is multi-session padding.

There are ways round problem 2, but not 1. I am desperate. Am I the only one with this sort of problem?
(I am using Nero and XP.)