optimizations

some code improvements