Optimizations for the patch (before it was just to be highly understandable)