more efficient(?) cleanup code
!!!!!!require C++11!!!!!!