Better indexing

A bunch of changes here, but the main one is 6a9ef8e.