safer file removal + db improvements