fix multiple crazy bugs causing retainer db not being connected to correctly