Cleaned up reference logic