small optimization fixes