Abstract similar code used when loading saves or loading classes

Fixes #1046
Merge pull request #1047 from dorkster/fixes

Abstract similar code used when loading saves or loading classes
Merge remote-tracking branch 'upstream/master'