Error 5823 when purging record map batch

I have an above error when purging record map batches and was wondering if anyone  out there has ever experienced this and if they have please any advice

Failed to purge body for header 9747192, BodyClassname='******.Batch':ERROR #5823: Cannot delete object, referenced by '*****.Record.%ParentBatch'

Comments

After some investigation on the above problem I realised that when purging record map data the data integrity check is the problem as I am using Ensemble 2014.1 the relationships on those is a  one to many so  when deleting these objects there is an %ondelete method which invokes a delete record method which tries to delete a record and then delete the batch but it does not check if that batch still have records associated with it. Now a new problem arises where I have tried to delete individuals records in a batch successfully but when trying to delete the batch its self it errors with a 5002 ROLLback error now the question is how to get around this problem