fixes for optimization