Leak fixes

This pull request contains a collection of changes to:

- allow Icy to release more memory when the Script Editor is closed
- save the editor state more often (when opening and closing files) to prevent state loss when Icy crashes  (of course it should not crash ;) )