Adds in converting from one database type to another

also fixes various bugs