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)
Merge pull request #1 from kargakis/refactor

Refactor where appropriate