Removed case expressions from inner loops
General cleanup in Optimize
General cleanup in LineSearch