Fixed code generator issues relating to handling adding to list