Some code optimizations