general bugfixes and code cleanup

-shutdown and update now properly dispose of the SQL database connection
and the log file handle.
-update sort of works on windows, still needs to be tested on linux
-after updating, will check if update was successful