Index: kernel/genarch/src/acpi/madt.c
===================================================================
--- kernel/genarch/src/acpi/madt.c	(revision e9f4b59711cfd45a8b880bf5c0fb44d93e815fd6)
+++ kernel/genarch/src/acpi/madt.c	(revision 0c61955d1de286c187f2c43fd9ba4639dda1db5a)
@@ -111,5 +111,5 @@
 	return ((struct madt_l_apic *)
 	    madt_entries_index[madt_l_apic_entry_index + i])->apic_id ==
-	    l_apic_id();
+	    bsp_l_apic;
 }
 
@@ -147,6 +147,8 @@
 static void madt_l_apic_entry(struct madt_l_apic *la, size_t i)
 {
-	if (!madt_l_apic_entry_cnt++)
+	if (madt_l_apic_entry_cnt == 0)
 		madt_l_apic_entry_index = i;
+	
+	madt_l_apic_entry_cnt++;
 	
 	if (!(la->flags & 0x1)) {
@@ -160,5 +162,5 @@
 static void madt_io_apic_entry(struct madt_io_apic *ioa, size_t i)
 {
-	if (!madt_io_apic_entry_cnt++) {
+	if (madt_io_apic_entry_cnt == 0) {
 		/* Remember index of the first io apic entry */
 		madt_io_apic_entry_index = i;
@@ -167,4 +169,6 @@
 		/* Currently not supported */
 	}
+	
+	madt_io_apic_entry_cnt++;
 }
 
@@ -190,5 +194,5 @@
 	/* Count MADT entries */
 	unsigned int madt_entries_index_cnt = 0;
-	for (hdr = &acpi_madt->apic_header[0]; hdr < end;
+	for (hdr = acpi_madt->apic_header; hdr < end;
 	    hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length))
 		madt_entries_index_cnt++;
@@ -196,5 +200,5 @@
 	/* Create MADT APIC entries index array */
 	madt_entries_index = (struct madt_apic_header **)
-	    malloc(madt_entries_index_cnt * sizeof(struct madt_apic_header **),
+	    malloc(madt_entries_index_cnt * sizeof(struct madt_apic_header *),
 	    FRAME_ATOMIC);
 	if (!madt_entries_index)
@@ -203,7 +207,9 @@
 	size_t i = 0;
 	
-	for (hdr = &acpi_madt->apic_header[0]; hdr < end;
-	    hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length))
-		madt_entries_index[i++] = hdr;
+	for (hdr = acpi_madt->apic_header; hdr < end;
+	    hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length)) {
+		madt_entries_index[i] = hdr;
+		i++;
+	}
 	
 	/* Sort MADT index structure */
