Adding function to reboot, moving code around for clarity.