Somehow fixing the patch functionality and also improving its performance just a bit.