BTW, here's an updated version of the patch with some issues I noticed rectified.