Fix minor generation bug, reformat CLI parsing.
diff --git a/generator/cper-generate-cli.c b/generator/cper-generate-cli.c
index 5d9c01e..0f0399b 100644
--- a/generator/cper-generate-cli.c
+++ b/generator/cper-generate-cli.c
@@ -5,6 +5,7 @@
  **/
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include "../edk/Cper.h"
 #include "cper-generate.h"
@@ -19,24 +20,51 @@
 		return 0;
 	}
 
-	//Ensure the minimum number of arguments.
-	if (argc < 5) {
-		printf("Insufficient number of arguments. See 'cper-generate --help' for command information.\n");
+	//Parse the command line arguments.
+	char *out_file = NULL;
+	char **sections = NULL;
+	UINT16 num_sections = 0;
+	for (int i = 1; i < argc; i++) {
+		if (strcmp(argv[i], "--out") == 0 && i < argc - 1) {
+			out_file = argv[i + 1];
+			i++;
+		} else if (strcmp(argv[i], "--sections") == 0 && i < argc - 1) {
+			//All arguments after this must be section names.
+			num_sections = argc - i - 1;
+			sections = malloc(sizeof(char *) * num_sections);
+			i++;
+			
+			for (int j = i; j < argc; j++)
+				sections[j - i] = argv[j];
+			break;
+		} else {
+			printf("Unrecognised argument '%s'. For command information, refer to 'cper-generate --help'.\n",
+			       argv[i]);
+			return -1;
+		}
+	}
+
+	//If no output file passed as argument, exit.
+	if (out_file == NULL) {
+		printf("No output file provided. For command information, refer to 'cper-generate --help'.\n");
 		return -1;
 	}
 
 	//Open a file handle to write output.
-	FILE *cper_file = fopen(argv[2], "w");
+	FILE *cper_file = fopen(out_file, "w");
 	if (cper_file == NULL) {
 		printf("Could not get a handle for output file '%s', file handle returned null.\n",
-		       argv[2]);
+		       out_file);
 		return -1;
 	}
 
 	//Generate the record. Type names start from argv[4].
-	UINT16 num_sections = argc - 4;
-	generate_cper_record(argv + 4, num_sections, cper_file);
+	generate_cper_record(sections, num_sections, cper_file);
+
+	//Close & free remaining resources.
 	fclose(cper_file);
+	if (sections != NULL)
+		free(sections);
 }
 
 //Prints command help for this CPER generator.
diff --git a/generator/sections/gen-section-cxl-protocol.c b/generator/sections/gen-section-cxl-protocol.c
index e0570b4..3ff6fbb 100644
--- a/generator/sections/gen-section-cxl-protocol.c
+++ b/generator/sections/gen-section-cxl-protocol.c
@@ -36,7 +36,7 @@
     if (cxl_agent_type == 0)
     {
         for (int i=0; i<3; i++)
-            *(bytes + 20 + i) = 0; //CXL agent address bytes 5-7.
+            *(bytes + 21 + i) = 0; //CXL agent address bytes 5-7.
     }
     
     *(bytes + 34) &= ~0b111; //Device ID byte 10 bits 0-2.
diff --git a/generator/sections/gen-section-pci-bus.c b/generator/sections/gen-section-pci-bus.c
index 406a27e..dc2381d 100644
--- a/generator/sections/gen-section-pci-bus.c
+++ b/generator/sections/gen-section-pci-bus.c
@@ -23,7 +23,7 @@
     UINT32* reserved = (UINT32*)(bytes + 20);
     *reserved = 0;
     UINT64* bus_command = (UINT64*)(bytes + 40);
-    *bus_command &= (0b1 << 56); //Bus command bytes bar bit 56.
+    *bus_command &= ((UINT64)0b1 << 56); //Bus command bytes bar bit 56.
 
     //Fix values that could be above range.
     UINT16* error_type = (UINT16*)(bytes + 16);