Solution now is only deleted when creatin/deleting sections from the courses window.
Improved restrictions checking before optimizing.