Use better way to override third-party functions:
Now we correctly restore functions with other wrappers and patches