Tangent optimization fix and debug build for sam