Fix and optimize