PHASE 1: divide $ref expansion process into seperate functions

locating $refs is now contained in it's own function json_locate_refs.