Just an observation - if you compute expDelta by doing PSP_SAS_ENVELOPE_HEIGHT_MAX - height_ instead of  the opposite, you get the sign flip for free.