Moved latest commit fetching

The latest commit would not be fetched if the program was run for the first time.
Catch exceptions
Added check for JSON null.