Fixed issue with DB saving

Would insert duplicates sometimes, fixed.