fixed database bugs, files are now inserted at scan time