Fixed setters, where SG_UNREF was called before SG_REF.
Found even more critical places.
Even more classes with displaced SG_REF/SG_UNREF
Swapping SG_REF / SG_UNREF in critical places.
Merge pull request #1564 from tklein23/sgref_before_sgunref

SG_REF before SG_UNREF