Fixed various bugs with db, import