various fixes after move to postgres