Code updates and optimizations