diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed0e7e44b5e92fa10b1cd9df8fa8e4554de30bc0..e91185cee058aa0989f6785d20d998ee88d7b092 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ project(xtc-length)
 cmake_minimum_required(VERSION 2.8)
 
 if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -O2")
 endif()
 
 add_executable(xtc-length xtc-length.c)
diff --git a/README.md b/README.md
index b3692c16cce6ffe59fab2bd45aa72da1c98d1d8a..7b8e38303fa17a2b4763487f1907ece7e0706e87 100644
--- a/README.md
+++ b/README.md
@@ -11,4 +11,4 @@ If you with to install to a directory other than default use `cmake . -DCMAKE_IN
 
 Since there is only one source file it is also possible to call the compiler directly if you prefer:
 
-`gcc -std=gnu90 -o xtc-length xtc-length.c`
+`gcc -o xtc-length xtc-length.c`
diff --git a/xtc-length.c b/xtc-length.c
index 07fa82468b6208f5dc153cd92456f1b2a2428af3..c34ed8d542bf440138b864a0ce0868f031aa1183 100644
--- a/xtc-length.c
+++ b/xtc-length.c
@@ -30,34 +30,37 @@ void print_header(const uint8_t header[92]){
 }
 
 int get_xtc_num_frames(const char *filename, int *nframes, int *natoms, float *psec, bool quiet){
+    uint8_t header[92];
+    uint32_t frame_size;
+    uint32_t skip;
+    uint32_t ps_tmp;
     long size = file_size(filename);
+    double avg_frame_size = 0.;
+    int est_nframes = 0;
 
     FILE *xtc = fopen(filename, "rb");
     if(!xtc) return -1;
 
-    uint8_t header[92];
 
     *nframes = 0;
-    double avg_frame_size = 0.;
-    int est_nframes = 0;
-    while(fread(header, 92, 1, xtc)){                       // Loop over frames
+    while(fread(header, 92, 1, xtc)){                       /* Loop over frames */
         (*nframes)++;
         *natoms = u4_from_buffer(header+4);
-        uint32_t frame_size = u4_from_buffer(header+88);    // Read frame size from header
-        uint32_t skip = (frame_size+3) & ~((uint32_t)3);    // Round up to 4 bytes
+        frame_size = u4_from_buffer(header+88);    /* Read frame size from header */
+        skip = (frame_size+3) & ~((uint32_t)3);    /* Round up to 4 byte boundary */
         avg_frame_size += (skip - avg_frame_size + 92) / *nframes;
         if(!quiet && *nframes % 10 == 0){
             est_nframes = (int)(size / avg_frame_size);
-            uint32_t ps_tmp = u4_from_buffer(header+12);
+            ps_tmp = u4_from_buffer(header+12);
             memcpy(psec, &ps_tmp, 4);
             *psec *= (double)est_nframes / *nframes;
             printf("\rEstimated %'d frames (%'d ns) of %'d atoms. - %d%%",
                     est_nframes, (int)(*psec/1000), *natoms, (int)(100. * *nframes) / est_nframes);
             fflush(stdout);
         }
-        fseeko(xtc, skip, SEEK_CUR);                         // Skip to next header
+        fseeko(xtc, skip, SEEK_CUR);                         /* Skip to next header */
     }
-    uint32_t ps_tmp = u4_from_buffer(header+12);
+    ps_tmp = u4_from_buffer(header+12);
     memcpy(psec, &ps_tmp, 4);
 
     fclose(xtc);
@@ -69,6 +72,10 @@ int main(const int argc, const char *argv[]){
                             "Usage: xtc-length [-q] xtc [xtc]...\n\n"
                             "Default behaviour is to provide running estimate of file length\n"
                             "This can be suppressed using the '-q' flag\n";
+    int i;
+    bool quiet = false;
+    int nframes, natoms;
+    float psec;
 
     setlocale(LC_ALL, "");
 
@@ -76,13 +83,9 @@ int main(const int argc, const char *argv[]){
         printf("%s", help_text);
         return 0;
     }
-    bool quiet = false;
     if(argc >= 2 && !strcmp(argv[1], "-q")) quiet = true;
 
-    int i;
     for(i = quiet ? 2 : 1; i < argc; i++){
-        int nframes, natoms;
-        float psec;
         printf("%s\n", argv[i]);
         if(get_xtc_num_frames(argv[i], &nframes, &natoms, &psec, quiet)){
             printf("ERROR: Error reading XTC file\n");