More refactoring of the track cleanup code
Algorithm is still the same... now need to know what it really meant to do