sgx: merge some of the improvements

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>