Optimizations

Ups, I forgot to create a task for this. Delegate can not be used, because it does not work with labdas with captures