Add isa function to Reference class
tidy up codes