Code cleanup. Generating refences