Improve 'lime upgrade' behavior and fix S3D builds