Some source code patches for V2.31

Just tried it out, working great from 2.31 … thanks for sharing!