Here is a hack for anyone in a similar situation.
I tried to change as little as I can.
The line numbers might not match with 2.1.7 vanilla because I made some other changes.
So if a patch run fails, then try editing manually or match the line numbers in the diff below to your real line numbers.
[originally posted on jforum.net by bcc]