Implement compiling of references and lets