Code cleanup and made JSON output as bearable as JSON gets.