C++11

Reference #1401.

Change much stuff to use new library.
These functions could use some documentation - what kind of values they return, thread safety etc..