Gateway switch script.
Resolved conflicts
Merged with master.