optimization fixes