Optimization of some code.