Moved REST logic to a util class; added logic to detect empty OIs in JSON stream