Added ScopeGuard from the Loki library. It provides a very simple mechanism to write exception-safe code. Have a look at the article: http://www.ddj.com/cpp/184403758
The basic idea is to make a scope guard and pass it a function to be called in case you don't call the guard's dismiss() function. And you always do this in the linear code order exception if it was interrupted by an exception. This way you can make sure that resources are being freed in any case.