deadlock handling, bugfix and optimization for db delete operations