few code optimizations