Generating code for lists and single element access