diff --git a/modules/io/src/img/map_io_dx_handler.cc b/modules/io/src/img/map_io_dx_handler.cc
index e25e95ab0da1e0d9efcb5c316acad66c22747629..4509d327d51187961802658a214d69c8b8bdf245 100644
--- a/modules/io/src/img/map_io_dx_handler.cc
+++ b/modules/io/src/img/map_io_dx_handler.cc
@@ -24,6 +24,7 @@
 #include <sstream>
 
 #include <ost/log.hh>
+#include <ost/string_ref.hh>
 #include <boost/iostreams/filter/gzip.hpp>
 #include <boost/iostreams/filtering_stream.hpp>
 #include <boost/filesystem/fstream.hpp>
@@ -45,6 +46,23 @@ namespace ost { namespace io {
 
 using boost::format;
 
+namespace {
+
+bool IEquals(const StringRef& a, const StringRef& b)
+{
+  if (a.size()!=b.size()) {
+    return false;
+  }
+  for (size_t i=0; i<a.size(); ++i) {
+    if (toupper(a[i])!=b[i]) {
+      return false;
+    }
+  }
+  return true;
+}
+
+}
+
 String DX::FORMAT_STRING="defined_dx";
 
 DX::DX (bool normalize_on_save):
@@ -97,6 +115,9 @@ void MapIODxHandler::Import(img::MapHandle& mh, std::istream& infile, const Imag
   img::MapHandle mh2;
   std::vector<String> tokens;
   while (std::getline(infile,line)) {
+    if (line.empty()) {
+      continue;
+    }
     // read gridpoints line
     if (boost::iequals(line.substr(0,35), "object 1 class gridpositions counts")) {
       boost::split(tokens, line, boost::is_any_of(" "), boost::token_compress_on);
@@ -189,14 +210,14 @@ void MapIODxHandler::Import(img::MapHandle& mh, std::istream& infile, const Imag
       Real value=0;
       for(int i=0; i<num_gridpoints; i+=3) {
         std::getline(infile,line);
-        boost::split(tokens, line, boost::is_any_of(" "), boost::token_compress_on);
-        for (size_t j=0; j<tokens.size()-1; j++) {  // three values per line
-          try {
-            value=boost::lexical_cast<Real>(boost::trim_copy(tokens[j]));
-          } catch(boost::bad_lexical_cast&) {
-            format fmer = format("Bad value line: Can't convert grid point value '%s' to Real constant.") % line;
-            throw IOException(fmer.str());
-          } 
+        StringRef curr_line(line.c_str(), line.size());
+        std::vector<StringRef> fields=curr_line.split(' ');
+        for (size_t j=0; j<fields.size(); j++) {
+          std::pair<bool, float> result=fields[j].trim().to_float();
+          if (!result.first) {
+            throw IOException((format("Bad value line: Can't convert grid point value '%s' to Real constant.") % line).str());
+          }
+          value=result.second;
           mh2.SetReal(img::Point(((i+j)/(v_size*w_size))%u_size,((i+j)/w_size)%v_size, (i+j)%w_size), value);
         }
       }