another bunch of changes concerning database, some other fixes