Performance improvements as suggested by Sergey in GIRAPH-931.