Fixed issue with saving in background.
tc.
Small refactoring.