Majority of db class rebuilt to use mysqli