Small performance improvements, to be tested though