Additional Error checks and DB cleaning