In addition to efficiency, this change also eliminates some nondeterminsm resulting from HashMap key ordering.