In depth code performance optimization

In depth code performance optimization