Updated to commit changes on reboot. Will also now reboot remote system not local system script is run on.
Simplified code.