Clean up naive nearest neighbors code