Made the policy validation and exec code more robust