DB: Several runtime error fixes