Working, but slow, refclass implementation