Fixed a few more database cleanup errors in code