I have made some code optimizations. 

I have made some code optimizations. The behaviour should not change. Very usefull code for me. Thanks!