merging RTS code from fork