Revert "disable unsafe optimization"

This reverts commit 527cf3a40c3a697e93fe2501257b54d98c60a427.