fix infinite loop from json parsing and
fix some core dumps.