Cleaned up quite a bit of my code for proximity statistics.