diff --git a/include/FLAC/format.h b/include/FLAC/format.h
index e4c1c1a..e02388c 100644
--- a/include/FLAC/format.h
+++ b/include/FLAC/format.h
@@ -509,9 +509,11 @@ typedef enum {
 	FLAC__METADATA_TYPE_PICTURE = 6,
 	/**< <A HREF="../format.html#metadata_block_picture">PICTURE</A> block */
 
-	FLAC__METADATA_TYPE_UNDEFINED = 7
+	FLAC__METADATA_TYPE_UNDEFINED = 7,
 	/**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */
 
+        FLAC__MAX_METADATA_TYPE = FLAC__MAX_METADATA_TYPE_CODE,
+        /**< No type will ever be greater than this. There is not enough room in the protocol block. */
 } FLAC__MetadataType;
 
 /** Maps a FLAC__MetadataType to a C string.
diff --git a/include/FLAC/stream_decoder.h b/include/FLAC/stream_decoder.h
index 152643f..49b031e 100644
--- a/include/FLAC/stream_decoder.h
+++ b/include/FLAC/stream_decoder.h
@@ -204,6 +204,9 @@ typedef enum {
 	FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0,
 	/**< The decoder is ready to search for metadata. */
 
+	FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
+	/**< Initialization was successful. */
+
 	FLAC__STREAM_DECODER_READ_METADATA,
 	/**< The decoder is ready to or is in the process of reading metadata. */
 
@@ -235,29 +238,12 @@ typedef enum {
 	 * state and can no longer be used.
 	 */
 
-	FLAC__STREAM_DECODER_UNINITIALIZED
+	FLAC__STREAM_DECODER_UNINITIALIZED,
 	/**< The decoder is in the uninitialized state; one of the
 	 * FLAC__stream_decoder_init_*() functions must be called before samples
 	 * can be processed.
 	 */
 
-} FLAC__StreamDecoderState;
-
-/** Maps a FLAC__StreamDecoderState to a C string.
- *
- *  Using a FLAC__StreamDecoderState as the index to this array
- *  will give the string equivalent.  The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderStateString[];
-
-
-/** Possible return values for the FLAC__stream_decoder_init_*() functions.
- */
-typedef enum {
-
-	FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
-	/**< Initialization was successful. */
-
 	FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
 	/**< The library was not compiled with support for the given container
 	 * format.
@@ -279,7 +265,19 @@ typedef enum {
 	 * FLAC__stream_decoder_finish() was not called.
 	 */
 
-} FLAC__StreamDecoderInitStatus;
+} FLAC__StreamDecoderState;
+
+/** Maps a FLAC__StreamDecoderState to a C string.
+ *
+ *  Using a FLAC__StreamDecoderState as the index to this array
+ *  will give the string equivalent.  The contents should not be modified.
+ */
+extern FLAC_API const char * const FLAC__StreamDecoderStateString[];
+
+
+/** Possible return values for the FLAC__stream_decoder_init_*() functions.
+ */
+typedef FLAC__StreamDecoderState FLAC__StreamDecoderInitStatus;
 
 /** Maps a FLAC__StreamDecoderInitStatus to a C string.
  *
diff --git a/src/flac/utils.c b/src/flac/utils.c
index 4bf05e2..941a958 100644
--- a/src/flac/utils.c
+++ b/src/flac/utils.c
@@ -35,7 +35,7 @@
 #ifdef HAVE_TERMIOS_H
 # include <termios.h>
 #endif
-#ifdef GWINSZ_IN_SYS_IOCTL
+#if !defined __ANDROID__
 # include <sys/ioctl.h>
 #endif
 #endif
diff --git a/src/libFLAC/cpu.c b/src/libFLAC/cpu.c
index f461439..fd2188e 100644
--- a/src/libFLAC/cpu.c
+++ b/src/libFLAC/cpu.c
@@ -87,22 +87,25 @@ static void sigill_handler (int sig)
 /* how to get sysctlbyname()? */
 #endif
 
+#ifdef FLAC__CPU_IA32
 /* these are flags in EDX of CPUID AX=00000001 */
 static const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_FXSR = 0x01000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE = 0x02000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000;
+#endif
 /* these are flags in ECX of CPUID AX=00000001 */
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE41 = 0x00080000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE42 = 0x00100000;
+#ifdef FLAC__CPU_IA32
 /* these are flags in EDX of CPUID AX=80000001 */
 static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW = 0x80000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW = 0x40000000;
 static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX = 0x00400000;
-
+#endif
 
 /*
  * Extra stuff needed for detection of OS support for SSE on IA-32
diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c
index 1af0b0d..161baed 100644
--- a/src/libFLAC/metadata_object.c
+++ b/src/libFLAC/metadata_object.c
@@ -440,7 +440,7 @@ FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type
 {
 	FLAC__StreamMetadata *object;
 
-	if(type > FLAC__MAX_METADATA_TYPE_CODE)
+	if(type > FLAC__MAX_METADATA_TYPE)
 		return 0;
 
 	object = calloc(1, sizeof(FLAC__StreamMetadata));
