Added few optimizations.