Updated database backend to handle seconday indexes less retardedly.