Fixes bugs after database change (4.0)