Added proximity calculations and tests