fixes #643 - case incorrect
fixed: potential sql error when deleting records
Merge branch 'master' into audit