Fixed order of destruction.
Added support for VS2013 and refactored code for easier addition of new VS versions.