json; fixed bugs, added pretty print, improved consistency.