DB sync, lots of bugfixes in DB connection