Set vars to null after deleting them when they will be reused. Thanks @Kernald.
Also switch to nullptr instead of NULL. This means enabling c++11 as well.