fix two bugs which were causing graph JSON endpoints to 500 error