tools: Improve patex script.