Misc. changes to support new JSON format. Still unstable.