fix bugs introduced with postgres migration