Moved to new encoding model based off of encoding/json. Also moved err check to after output check to speed up response.