Hotfix gallery error (empty gallery crash and incorrect restore instance state).