Fixed some memory leaks by using unique_ptr in Scopes and ScopedNodes internally