Fix for database lock problem