Adding comments to getClosestN and certain function modifications