Minor changes, faster lookup ids using kdtrees