Design and correction of optical systems