style and optimization fixes