db integration and orphaned files cleanup