Minor cosmetic changes; use squared norm instead of euclidean distance (one less computation, same result as it is used to compare distances)