Adding indexes for efficiency and to stop recursive locks.