Some otimization was added.

Signed-off-by: Yuriy Rusinov <yrusinov@gmail.com>