Clean and refactor. Output json from newick.