Add wx_ptr and use it instead of ScopeGuard in a lot of places.