docstrings and add JSON pretty-printing code