Remove unused code. Trap errors in JSON processing