This should be it for now... maybe extend... it needs modularisation of $ref