Some code and image optimizations