More code cleanup with respect to generating references