Fixed db getting so it's only done once.