Made autoupdater more robust with exception catching.
Refactored autoupdate code into functions. Added restart after update.