#2452 Fix memory leak and local/global/local indexing problem (see r20458)

git-svn-id: https://chaste.cs.ox.ac.uk/svn/chaste/trunk@20459 b5f69653-2bf5-0310-8201-b0dafb8e1405
#2452 Another go at local/global/local indexing problem (see r20458 r20459)

git-svn-id: https://chaste.cs.ox.ac.uk/svn/chaste/trunk@20460 b5f69653-2bf5-0310-8201-b0dafb8e1405
#2449 Much more elegant algorithm.

git-svn-id: https://chaste.cs.ox.ac.uk/svn/chaste/trunk@20462 b5f69653-2bf5-0310-8201-b0dafb8e1405