Correctly handle references