Fixed bugs in the 'references' implementation