Refactor where appropriate

Check for errors immediately after an error has been returned from a
function call, add error checking after ReadAll calls, and move
json.Unmarshal calls into their following if statements(more idiomatic)