more optimization fixes