fixed bugs with constructing db handles in daemon and pm