Stack Inspection and Secure Program Transformations