Fix db filenames

As of python 3, the shelve module assumes the file you're trying to open ends in .db and adds that extension itself. Opening 'core.db' on python 3 results in a file 'core.db.db' being created.

These two commits should fix this, automatically moving any '.db.db' files to their respective '.db' location when first opened.