Fix crash when clearing document and loading file
Implement loading of layer groups
Fix saving and loading of selected layer