Some fixes in GP framework
SG_UNREF added to prevent memory leak