Fixed memory leak in scale-patch (squash with previous commit)