added autosave flag and edge cases for loading layouts.