Modified DB code to close its connection if right after its finished with it, helps performance-wise and should resolve locked db issues as well.