Backport improvements and fixes to our RTS engine.