Fixed reference manager logic - was incorrectly adding references