diff --git a/Simplex.h b/Simplex.h
index 1c1a5ffd54dcb8e78582f1cd73f62eeb2dd20237..3afbf752156fa91a3cad030fe68b935dcb9de480 100644
--- a/Simplex.h
+++ b/Simplex.h
@@ -75,14 +75,14 @@ public:
   /// Update the indicies for best, worst and 2nd to worst points.
   void UpdateRankIndicies();
   // Global function. Prints out the points of the simplex and the associated function values
-  friend ostream& operator<<(ostream& op, const Simplex& smplx)
+  friend std::ostream& operator<<(std::ostream& op, const Simplex& smplx)
   {
-    op << "Simplex = " << endl;
+    op << "Simplex = " << std::endl;
     for (unsigned int i=0; i<smplx._smx.size(); i++) {
       for (unsigned int j=1; j<smplx._smx.size(); j++) {
 	op << std::setw(10) << std::setprecision(4) << smplx._smx[i](j);
       }
-      op << " | " << std::setw(10) << std::setprecision(4) << smplx._fv[i] << endl;
+      op << " | " << std::setw(10) << std::setprecision(4) << smplx._fv[i] << std::endl;
     }
     return(op);
   }
diff --git a/SpMat.h b/SpMat.h
index e4f5ce4cb5de340084fa1ce81814f6ef7c874ccf..0b35796b25d801fbf15f80d310a1d07996b17fa9 100644
--- a/SpMat.h
+++ b/SpMat.h
@@ -40,7 +40,7 @@ public:
   SpMatException(const std::string& msg) throw(): m_msg(msg) {}
 
   virtual const char * what() const throw() {
-    return string("SpMat::" + m_msg).c_str();
+    return std::string("SpMat::" + m_msg).c_str();
   }
 
   ~SpMatException() throw() {}
@@ -318,11 +318,11 @@ public:
   T& operator()(unsigned int i);
   unsigned int NO() const {return(_no);}
   unsigned int ri(unsigned int i) {                             // Index of i'th non-zero value.
-    if (!_sorted) {sort(_occi,&(_occi[_no])); _sorted=true;}
+    if (!_sorted) {std::sort(_occi,&(_occi[_no])); _sorted=true;}
     return(_occi[i]);
   }
   const T& val(unsigned int i) {                                // i'th non-zero value. Call ri(i) to find what index that corresponds to
-    if (!_sorted) {sort(_occi,&(_occi[_no])); _sorted=true;}
+    if (!_sorted) {std::sort(_occi,&(_occi[_no])); _sorted=true;}
     return(_val[_occi[i]]);
   }
   const T& val_at(unsigned int i) const {return(_val[i]);}      // Value for index i (or i+1)
@@ -515,28 +515,28 @@ template<class T>
 void SpMat<T>::Print(const std::string&  fname,
                      unsigned int        precision) const
 {
-  ostream  *sptr=0;
+  std::ostream  *sptr=0;
 
   if (!fname.length()) {
-    sptr = &cout;
+    sptr = &std::cout;
   }
   else {
     try {
-      sptr = new ofstream(fname.c_str());
+      sptr = new std::ofstream(fname.c_str());
     }
     catch(...) {
       std::string  errmsg("BFMatrix::print: Failed to write to file " + fname);
       throw SpMatException(errmsg);
     }
   }
-  (*sptr) << setprecision(precision);
+  (*sptr) << std::setprecision(precision);
 
   for (unsigned int c=0; c<_n; c++) {
     for (unsigned int i=0; i<_ri[c].size(); i++) {
-      if (_val[c][i]) (*sptr) << _ri[c][i]+1 << "  " << c+1 << "  " << _val[c][i] << endl;
+      if (_val[c][i]) (*sptr) << _ri[c][i]+1 << "  " << c+1 << "  " << _val[c][i] << std::endl;
     }
   }
-  (*sptr) << _m << "  " << _n << "  " << 0 << endl;
+  (*sptr) << _m << "  " << _n << "  " << 0 << std::endl;
 
   if (fname.length()) delete sptr;
 }
@@ -616,9 +616,9 @@ NEWMAT::ReturnMatrix SpMat<T>::SolveForx(const NEWMAT::ColumnVector&
   }
 
   if (status && _pw) {
-    cout << "SpMat::SolveForx: Warning requested tolerence not obtained." << endl;
-    cout << "Requested tolerance was " << ltol << ", and achieved tolerance was " << tol << endl;
-    cout << "This may or may not be a problem in your application, but you should look into it" << endl;
+    std::cout << "SpMat::SolveForx: Warning requested tolerence not obtained." << std::endl;
+    std::cout << "Requested tolerance was " << ltol << ", and achieved tolerance was " << tol << std::endl;
+    std::cout << "This may or may not be a problem in your application, but you should look into it" << std::endl;
   }
 
   x.Release();
diff --git a/bfmatrix.cpp b/bfmatrix.cpp
index 541990b6abbe6aa8215220c7c3f1e3dfbe4af6e1..81bd9689a0c0c8096964a4655cbea1cafa492516 100644
--- a/bfmatrix.cpp
+++ b/bfmatrix.cpp
@@ -15,6 +15,8 @@
 #include "miscmaths.h"
 #include "bfmatrix.h"
 
+using namespace std;
+
 namespace MISCMATHS {
 
 //
diff --git a/bfmatrix.h b/bfmatrix.h
index 4b63c3074c3e5a7a49100408148868f9c817559a..673bfc82653e60948e2b324a6f8e64eaf5966248 100644
--- a/bfmatrix.h
+++ b/bfmatrix.h
@@ -45,7 +45,7 @@ public:
   BFMatrixException(const std::string& msg) throw(): m_msg(msg) {}
 
   virtual const char * what() const throw() {
-    return string("BFMatrix::" + m_msg).c_str();
+    return std::string("BFMatrix::" + m_msg).c_str();
   }
 
   ~BFMatrixException() throw() {}
diff --git a/f2z.cc b/f2z.cc
index e700de6f9562804fc5ad45514d963ce7fc0de7ad..568fc5d6a925fbf8f4367da707d851e85ed68858 100644
--- a/f2z.cc
+++ b/f2z.cc
@@ -13,6 +13,7 @@
 #include "cprob/libprob.h"
 #include <stdexcept>
 
+using namespace std;
 using namespace NEWMAT;
 using namespace Utilities;
 
diff --git a/kernel.cc b/kernel.cc
index 60381b1714ef6163629693a8e93084d01015f1dd..5cf16aa133b2c6fa4dda7fa975f42c735565e305 100644
--- a/kernel.cc
+++ b/kernel.cc
@@ -9,6 +9,7 @@
 #include "kernel.h"
 #include "miscmaths.h"
 
+using namespace std;
 using namespace NEWMAT;
 
 namespace MISCMATHS {
diff --git a/kernel.h b/kernel.h
index 131084e48a76b4b7cf803fae684a1c729e597431..a3aaa5e6657ae45108f8355bd790120f22d2d70c 100644
--- a/kernel.h
+++ b/kernel.h
@@ -102,7 +102,7 @@ namespace MISCMATHS {
   class kernel
     {
     private:
-      static set<kernelstorage*, kernelstorage::comparer> existingkernels;
+      static std::set<kernelstorage*, kernelstorage::comparer> existingkernels;
       kernelstorage* storedkernel;
 
     public:
@@ -135,7 +135,7 @@ namespace MISCMATHS {
       {
 	// see if already in list:
 	storedkernel = new kernelstorage(kx,ky,kz,wx,wy,wz);
-	set<kernelstorage*, kernelstorage::comparer>::iterator
+    std::set<kernelstorage*, kernelstorage::comparer>::iterator
 	  it = existingkernels.find(storedkernel);
 	if (it==existingkernels.end()) {
 	  existingkernels.insert(storedkernel);
diff --git a/minimize.h b/minimize.h
index 5039346cc84c12c7180ac80bc23ef9592485ee40..c673cdc2c135e575e3ad739b7fe7ad313d30d8ff 100644
--- a/minimize.h
+++ b/minimize.h
@@ -29,7 +29,7 @@ namespace MISCMATHS {
 class pair_comparer
 {
 public:
-  bool operator()(const pair<float,NEWMAT::ColumnVector>& p1,const pair<float,NEWMAT::ColumnVector>& p2) const
+  bool operator()(const std::pair<float,NEWMAT::ColumnVector>& p1,const std::pair<float,NEWMAT::ColumnVector>& p2) const
   {
     return p1.first < p2.first;
   }
diff --git a/miscmaths.h b/miscmaths.h
index 97d1839585dc18d00acd64e3d3ded488054ab6d0..cd7180e690ae288ab3c724185318e6b5b136ef8e 100644
--- a/miscmaths.h
+++ b/miscmaths.h
@@ -300,7 +300,7 @@ namespace MISCMATHS {
   float digamma(const float x);
   void glm_vb(const NEWMAT::Matrix& X, const NEWMAT::ColumnVector& Y, NEWMAT::ColumnVector& B, NEWMAT::SymmetricMatrix& ilambda_B, int niters=20);
 
-  vector<float> ColumnVector2vector(const NEWMAT::ColumnVector& col);
+  std::vector<float> ColumnVector2vector(const NEWMAT::ColumnVector& col);
 
   ///////////////////////////////////////////////////////////////////////////
   // Uninteresting byte swapping functions
@@ -329,8 +329,8 @@ namespace MISCMATHS {
   template<class t> void write_vector(const std::string& fname, const std::vector<t>& vec)
   {
     std::ofstream out;
-    out.open(fname.c_str(), ios::out);
-    copy(vec.begin(), vec.end(), ostream_iterator<t>(out, " "));
+    out.open(fname.c_str(), std::ios::out);
+    copy(vec.begin(), vec.end(), std::ostream_iterator<t>(out, " "));
   }
 
   template<class t> void write_vector(const std::vector<t>& vec, const std::string& fname)
@@ -345,7 +345,7 @@ namespace MISCMATHS {
     if (width>0) {
       os.fill('0');
       os.width(width);
-      os.setf(ios::internal, ios::adjustfield);
+      os.setf(std::ios::internal, std::ios::adjustfield);
     }
     os << n;
     return os.str();
diff --git a/nonlin.h b/nonlin.h
index 14d254fb9995984737b12332ff2844245ab3ec01..cd23bbe305d93f07798a03a094f3a26336ef66ee 100644
--- a/nonlin.h
+++ b/nonlin.h
@@ -68,7 +68,7 @@ public:
   NonlinException(const std::string& msg) throw(): m_msg(msg) {}
 
   virtual const char * what() const throw() {
-    return string("Nonlin: msg=" + m_msg).c_str();
+    return std::string("Nonlin: msg=" + m_msg).c_str();
   }
 
   ~NonlinException() throw() {}
@@ -397,11 +397,11 @@ NonlinOut nonlin(const NonlinParam& p, const NonlinCF& cfo);
 
 // Declaration of global utility functions
 
-pair<NEWMAT::ColumnVector,NEWMAT::ColumnVector> check_grad(const NEWMAT::ColumnVector&  par,
-                                                           const NonlinCF&                     cfo);
+std::pair<NEWMAT::ColumnVector,NEWMAT::ColumnVector> check_grad(const NEWMAT::ColumnVector&  par,
+                                                                const NonlinCF&              cfo);
 
-pair<boost::shared_ptr<BFMatrix>,boost::shared_ptr<BFMatrix> > check_hess(const NEWMAT::ColumnVector& par,
-                                                                          const NonlinCF&     cfo);
+std::pair<boost::shared_ptr<BFMatrix>,boost::shared_ptr<BFMatrix> > check_hess(const NEWMAT::ColumnVector& par,
+                                                                               const NonlinCF&             cfo);
 
 } // End namespace MISCMATHS
 
diff --git a/sparse_matrix.h b/sparse_matrix.h
index e2c4f652a9aaaf73cdfbb6fbffead0afad82c583..992a40358882f03de356b3963774b82aaa895fd4 100644
--- a/sparse_matrix.h
+++ b/sparse_matrix.h
@@ -125,7 +125,7 @@ namespace MISCMATHS {
       int nrows;
       int ncols;
 
-      std::vector<map<int,double> > data;
+      std::vector<std::map<int,double> > data;
 
     };
 
diff --git a/splinterpolator.h b/splinterpolator.h
index 02091bd5b5bc288c5ee0e175b8cd99adc4ba2268..6366b83ab3ecc73d3eadc0903bf5982179e6d6a4 100644
--- a/splinterpolator.h
+++ b/splinterpolator.h
@@ -30,7 +30,7 @@ public:
   SplinterpolatorException(const std::string& msg) throw(): m_msg(msg) {}
 
   virtual const char *what() const throw() {
-    return string("Splinterpolator::" + m_msg).c_str();
+    return std::string("Splinterpolator::" + m_msg).c_str();
   }
 
   ~SplinterpolatorException() throw() {}
diff --git a/t2z.cc b/t2z.cc
index 4d05d2748f4f6ade504a5ed2dfe383d1f1d054cb..9026e6006d5f4e4d81e7108c019718892b8a911d 100644
--- a/t2z.cc
+++ b/t2z.cc
@@ -12,6 +12,7 @@
 #include "utils/tracer_plus.h"
 #include "cprob/libprob.h"
 
+using namespace std;
 using namespace NEWMAT;
 using namespace Utilities;